﻿using Customer.API.Applcation.Command.VendorCommand;
using Customer.Domain;
using Customer.Infrstructre.VendorManager;
using MediatR;
using System.Diagnostics.Contracts;
using System.Net;

namespace Customer.API.Applcation.CommandHandlers.VendorCommandHandler
{
    /// <summary>
    /// 修改供应商
    /// </summary>
    public class UpdVendorCommandHandler:IRequestHandler<UpdVendorCommand,int>
    {
        private readonly IVendorRepository _ivendorRep;
        public UpdVendorCommandHandler(IVendorRepository _ivendorRep)
        {
            this._ivendorRep = _ivendorRep;
        }

        public async Task<int> Handle(UpdVendorCommand request, CancellationToken cancellationToken)
        {
            var res = new Vendor() { VendorId = request.VendorId, VendorCode = request.VendorCode, VendorName = request.VendorName, VendorType = request.VendorType, Vphone = request.Vphone, Vfax = request.Vfax, Email = request.Email, Vcontact = request.Vcontact, Vaddress = request.Vaddress, CreatTime = request.CreatTime, Describe = request.Describe, State = request.State, Office_Id = request.Office_Id, User_Id = request.User_Id, AddName = request.AddName, AddTime = request.AddTime, UpdName = request.UpdName, UpdTime = request.UpdTime };
            return await _ivendorRep.Update(res);
        }
    }
}
